﻿<%--<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<CRM.Models.TrainingsCourses>>" %>--%>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<CRM.Database.Model.TrainingsCourses>>" %>
<%@ Import Namespace="CRM.Resourses" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Drawing" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdTrainingsCourse";
                                        settings.KeyFieldName = "IdTrainingsCourse";
                                        settings.CallbackRouteValues = new { Controller = "TC", Action = "TrainingsCoursesPartial" };
                                        settings.SettingsPager.PageSize = 20;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.CommandColumn.Visible = true;
                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsCourseName;
                                            column.FieldName = "Name";
                                        });

                                        
                                        //
                                        //Добавление комбобоксов
                                        //
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "IdTrainingCoursesType";
                                            column.Caption = Resourses.TrainingCoursesType;
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                var typesCol = new CRM.Database.Model.TrainingCoursesTypesCollection();
                                                comboBoxProperties.DataSource = typesCol.TrainingCoursesTypesList;
                                                //comboBoxProperties.DataSource = DB.GetLocalizedTrainingCoursesTypesNames(Thread.CurrentThread.CurrentCulture.ToString());
                                                comboBoxProperties.TextField = "LocalizedName";
                                                comboBoxProperties.ValueField = "IdTrainingCoursesType";
                                                //comboBoxProperties.ValueField = "Id";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });
                                        //конец комбобокса

                                        //
                                        //Добавление комбобоксов
                                        //
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "IdRubric";
                                            column.Caption = Resourses.TrainingsRubric;
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                var rubricsCol = new CRM.Database.Model.RubricsCollection();
                                                comboBoxProperties.DataSource = rubricsCol.RubricsList;
                                                //comboBoxProperties.DataSource = DB.GetLocalizedRubricsNames(Thread.CurrentThread.CurrentCulture.ToString());
                                                comboBoxProperties.TextField = "LocalizedName";
                                                comboBoxProperties.ValueField = "IdRubric";
                                                //comboBoxProperties.ValueField = "Id";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });
                                        //конец комбобокса

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsLinkToMaterial;
                                            column.FieldName = "LinkToMaterial";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsLinkToProgramm;
                                            column.FieldName = "LinkToProgramm";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsLinkToFeedBack;
                                            column.FieldName = "LinkToFeedBack";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsDescription;
                                            column.FieldName = "Description";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsDuration;
                                            column.FieldName = "Duration";
                                        });
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsParticipantCount;
                                            column.FieldName = "ParticipantCount";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsTrainersList;
                                            column.FieldName = "Trainers";
                                        });

                                        //settings.Columns.Add(column =>
                                        //{
                                        //    column.Caption = Resourses.TrainingsPlacesList;
                                        //    column.FieldName = "Places";
                                        //});

                                        

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsAudtoriumsList;
                                            column.FieldName = "Auditoriums";
                                        });
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.IsActive;
                                            column.FieldName = "IsActive";
                                            column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                        });

                                        //
                                        //Добавление редактирования
                                        //
                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "TC", Action = "TrainingsCoursesPartialUpdate" };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "TC", Action = "TrainingsCoursesPartialAdd" };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "TC", Action = "TrainingsCoursesPartialDelete" };
                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = Unit.Percentage(100);
                                        
                                    }).Bind(Model).GetHtml();%>


